package com.macro.mall.feign;

import com.macro.mall.dto.Code2Session;
import com.macro.mall.dto.WxAccessTokenReturn;
import com.macro.mall.dto.WxGetPhoneBody;
import com.macro.mall.dto.WxGetPhoneReturn;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@FeignClient(value = "wxFeignClient", url="https://api.weixin.qq.com")
public interface WxFeignClient {

    @GetMapping(value = "/cgi-bin/token?grant_type=client_credential&appid={appid}&secret={secret}", produces = {MediaType.APPLICATION_JSON_VALUE})
    WxAccessTokenReturn getAccessToken(@PathVariable String appid, @PathVariable String secret);

    @PostMapping(value = "/wxa/business/getuserphonenumber?access_token={accessToken}", produces = {MediaType.APPLICATION_JSON_VALUE})
    WxGetPhoneReturn getPhone(@RequestBody WxGetPhoneBody wxGetPhoneBody, @PathVariable String accessToken);

    @PostMapping(value = "/sns/jscode2session?appid={appId}&secret={secret}&js_code={jsCode}&grant_type=authorization_code", produces = {MediaType.APPLICATION_JSON_VALUE})
    Code2Session code2Session(@PathVariable String appId, @PathVariable String secret, @PathVariable String jsCode);




}
